package users

import (
	"errors"
	"orm_gin/model"
	"orm_gin/orm"
	"orm_gin/utools/res"

	"github.com/gin-gonic/gin"
)

// @BasePath /user

// @Summary 获取用户信息
// @Description token
// @Tags 用户表
// @Param Account query string true "Account"
// @Success 200 {object} docsmodel.Response
// @Router /user/pwd [get]
// @Security
func GetUserInfo(c *gin.Context) {
	id, ok := c.Get("UserId")
	if !ok {
		res.Error(c, 0, errors.New("无法获取用户ID"), "无法获取用户ID")
		return
	}

	var user model.UserInfo
	r := orm.DB.Where("id=?", id).Select("id", "nike_name", "email", "gender", "phone").Find(&user)
	if r.Error != nil {
		res.Error(c, 0, r.Error, "gorm 查询数据失败")
		return
	}

	res.Ok(c, user, "操作成功")

}
